<%@ page language="java" import="java.util.*,com.xiaobin.system.util.*"
	pageEncoding="UTF-8"%>
<%@ include file="/base/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>${systemOption.systemTitle}</title>
<%@ include file="/base/head.jsp"%>	
 <script language="javascript" src="${ctx}/js/LodopFuncs.js"></script>
    <script type="text/javascript" charset="UTF-8">
    //分页查询
	function doQuery() {
		var queryParams = $('#mailList').datagrid('options').queryParams;
		queryParams.startSendTime = $('#startTime').datebox('getValue');
		queryParams.endSendTime = $('#endTime').datebox('getValue');
		queryParams.subject = $('#searchsubject').val();
		//重置当前页数为1
		resetDG('#mailList');
	}
	 //详情
	 function detail(){
	 	var row = $('#mailList').datagrid('getSelected');
		if(!row){
			$.messager.alert('友情提示', '请选择行', 'error');
			return;
		}
		var url = "${ctx}/zhgl/replyMail.action?id="+row.id+"&type="+1;
		$('#replyIframe').attr("src",url);
		$('#xqdlg').show();
		$('#xqdlg').dialog({
			title:'写信',
			modal:true,
	    	maximized:true
		});
 }
 	function formatStatus(val,row){
		if(row.seen==1){
			return '<img alt="新邮件" src="${ctx }/images/icon/16/email.png">';
		}else{
			return '<img alt="已读邮件" src="${ctx }/images/icon/16/email_open.png">';
		}
	}
	
	/*
	 关闭回复窗口
	*/
	function closeReplyWin(){
		$('#xqdlg').dialog('close');
	}
	function removeMail(){
		var row = $('#mailList').datagrid('getSelected');
		if(!row){
			$.messager.alert('友情提示', '请选择要删除的行', 'error');
			return;
		}
		$.messager.confirm('友情提示', '将删除，确定么？', function(r) {
			if (r) {
				$.post("${ctx}/json/delMail.action", {
					"id" : row.id
				}, function(data) {
					if (data) {
						$.messager.alert('友情提示', '删除成功', 'info');
						resetDG('#mailList');
					} else {
						$.messager.alert('友情提示', '删除失败', 'error');
					}
				}, "json");
			}
		});
	}
	
	</script>

  </head>
  
  <body>
<!--         主窗口   	 -->
  	  <table id="mailList" class="easyui-datagrid" style="height:250px" data-options="
  	  									fit:true,
	    								rownumbers:true,
										singleSelect:true,
										striped:true,
										fitColumns:true,
										border:false,
										toolbar:'#tb',
										pagination:true,
										pageSize:20,
										nowrap:true,
										url:'${ctx}/json/listSendMail.action?isSave=1',
										onDblClickRow:detail">
			<thead>
				<tr>
					<th data-options="field:'ck',checkbox:true"></th>
					<th data-options="field:'isnew',align:'center',formatter:formatStatus" width="50px"></th>
					<th data-options="field:'jsrmc',align:'center'" width="150px"><strong>收件人</strong></th>
					<th data-options="field:'subject',align:'left'" width="500px"><strong>主题</strong></th>
					<th data-options="field:'sendTime',align:'center'" width="150px"><strong>发件时间</strong></th>
					<th data-options="field:'id',hidden:true"></th>
				</tr>
			</thead>
		</table>
<!--		 Datagrid工具栏 -->
		<div id="tb">
			<table width="100%" cellpadding="0" cellspacing="0">
				<tr>
				   	<td class="toolDiv">
				  		<a href="javascript:void(0)" onclick="removeMail();" class="easyui-linkbutton" data-options="iconCls:'icon-email-delete',plain:true" style="float:left;">删除</a>
					</td>
			   </tr>
				<tr>
					<td class="serchDiv">
						主题：<input id="searchsubject" class="easyui-validatebox" type="text"  style="width:200px">
						&nbsp;&nbsp; 发送时间：
						<input id="startTime" class="easyui-datebox" />至<input id="endTime" class="easyui-datebox"/>
						&nbsp;&nbsp;<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" 
										onclick="doQuery()">查询</a>
					</td>
				</tr>
			</table>
		</div>
<!--		 详情窗口     -->
		<div id="xqdlg" style="width:750px;overflow-x:hidden;overflow-y:auto;display: none">
				<iframe width="100%" height="99%" frameborder="0" align="top" 
    			scrolling="yes" id="replyIframe">
    		</iframe>
		</div>
  </body>
</html>
